public class demo2 {
    public static void main(String[] args) {
        Object locker1=new Object();
        Object locker2=new Object();
        Thread t=new Thread(()->{
            synchronized (locker1){
                System.out.println("第一把锁");
                synchronized (locker2){
                    System.out.println("没有死锁1");
                }
            }
        });
        Thread t2=new Thread(()->{
            synchronized (locker2){
                System.out.println("第二把锁");
                synchronized (locker2){
                    System.out.println("没有死锁2");
                }
            }
        });
        t.start();
        t2.start();
    }
}
